////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   CCY_EXCHANGE
// AUTHOR           :   Ric Yik 
// DATE CREATE      :   2006/01/11
// DESCRIPTION      :   The abstract class for the CustomOptionsTag used in this project
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/01/11   Ric Yik         1.0                 source is created.
//
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.app.util.web.taglib;

import javax.servlet.jsp.JspException;

import com.erp.framework.controller.taglib.CustomOptionsTag;

public abstract class ProjectCustomOptionsTag extends CustomOptionsTag {

    private boolean whereSelected = false;

    private String appendedWhere = "";

    /**
     * @see com.erp.framework.controller.taglib.CustomOptionsTag#setWhere(java.lang.String)
     */
    public void setWhere(String text) {
        super.setWhere(text);
        this.setWhereSelected(true);
    }

    /**
     * @return Returns the whereSelected.
     */
    protected boolean isWhereSelected() {
        return whereSelected;
    }

    /**
     * @param whereSelected The whereSelected to set.
     */
    protected void setWhereSelected(boolean whereSelected) {
        this.whereSelected = whereSelected;
    }

    public String getAppendedWhere() {
        return appendedWhere;
    }

    public void setAppendedWhere(String appendedWhere) {
        this.appendedWhere = appendedWhere;
    }

    /**
     * @see com.erp.framework.controller.taglib.CustomOptionsTag#doEndTag()
     */
    public int doEndTag() throws JspException {
        if (!this.isWhereSelected()) {
            this.setWhere(this.makeWhereClause() + ((this.getAppendedWhere().length() > 0) ? " " + this.getAppendedWhere() : ""));
        }
        int result = super.doEndTag();
        this.setWhereSelected(false);
        return result;
    }

    protected String makeWhereClause() {
        return "";
    }

}
